﻿
using System.Collections.Generic;
using System.Linq;
using Dexter.DataTransferObject;

namespace Dexter.Domain.Model {
	public static class CategoryHelper {
		public static IList<CategoryDto> ToDtos(this IEnumerable<Category> s)
		{
			return s.Select ( x => x.ToDto ( ) ).ToList (  );
		}

		public static CategoryDto ToDto(this Category s) {
			var r = new CategoryDto ( );

			r.ContentNumber = s.ContentNumber;
			r.FeedBurnerUrl = s.FeedBurnerUrl;
			r.Id = s.Id;
			r.IsDefaultCategory = s.IsDefaultCategory;
			r.Name = s.Name;

			if (s.Categories != null && s.Categories.Any ( )) {
				r.Categories = s.Categories.ToDtos ( );
			}

			return r;
		}
	}
}
